package solutions.leetcode.easy;

/**
 * @author lizhidong
 * <a href="https://leetcode-cn.com/problems/remove-element/">27. 移除元素</a>
 */
public class Solution27 {

    public int removeElement(int[] nums, int val) {
        int p = 0, e = 0;
        while (p < nums.length) {
            if (nums[p] != val) {
                nums[e++] = nums[p++];
            } else {
                p++;
            }
        }
        return e;
    }

    public static void main(String[] args) {
        Solution27 solution = new Solution27();
    }
}
